package com.fds.system.controller;

import com.fds.system.utils.AesUtils;
import com.fds.system.utils.RsaUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/demo")
public class DemoController {

    @Value("${rsa.secretKey}")
    private String secretKey;

    /**
     * aes解密接口
     * @param value
     * @return
     */
    @GetMapping("/decryptAes")
    public String decryptAes(String value) {
        return AesUtils.decode(AesUtils.DEFAULT_SECRET_KEY, value);
    }

    /**
     * rsa解密接口
     * @param value
     * @return
     */
    @GetMapping("/decryptRsa")
    public String decryptRsa(String value) throws Exception {
        return RsaUtils.decrypt(value, secretKey);
    }
}
